K.

includes("K.ui.Window").
includes("K.ui.ViewPort").
includes("K.dom.Element").

provides("K.manager.WindowManager").
run(function(I) {
	
	var WindowManager = K.kin(function(obj, viewPort) {
            var windows = {},
            
                initialize = function() {
                    viewPort.render();
                };
            
            K.merge(obj, {
                add : function(w) {
                    windows[w.id()] = w;
                    viewPort.add(w);
                }
            });
            
            
            initialize();
        }),
        
        defaultManager;
    	
	
	K.merge(WindowManager, {
		getDefaultManager : function() {
			if (!defaultManager) {
                var v = I.ViewPort();
                I.Element(document.body).append(v.element());
				defaultManager = WindowManager(v);
			}
			
			return defaultManager;
		}
	});
	
	return WindowManager;
});